<?php

namespace Apps\AppApi\Method\User;
use Apps\AppApi\Method\BaseMethod;
use Apps\Common\Models\UserMessage;
use PhalconPlus\Api\Common\ResultStatus;

/**
 * 我的消息列表
 * @package Apps\AppApi\Method\User
 */
class ClearMessage extends BaseMethod
{
    public function run()
    {
        if(!$this->verifyUserAuth()){
            return false;
        }

		if ($userId = $this->getUserAuth()->userId) {
			(new UserMessage())->getReadConnection()->query('DELETE FROM user_message WHERE user_id = ' . $userId);
			/*$result = (new UserMessage())->getReadConnection()->query('DELETE FROM user_message WHERE user_id = ' . $userId);
			if($result->numRows()){
				$this->setResult([
					'success' => 1,
					'message' => '清空成功！'
				]);
				return true;
			}*/
		}
		$this->setResult([
			'success' => 1,
			'message' => '清空成功！'
		]);
    }
}
